[%
<wizard>
	<page>
		<title>Select data type</title>
		<description>Select data type for which to create a strongly typed collection</description>
		<variable name="datatype"/>
	</page>	
</wizard>
%]using System;
using System.Collections;

namespace [%<variable name="namespace"/>%]
{

	public class [%<variable type="standard" name="filenamebase"/>%] : CollectionBase  
	{

		public [%<variable type="custom" name="datatype"/>%] this[ int index ]  
		{
			get  
			{
				return( ([%<variable type="custom" name="datatype"/>%]) List[index] );
			}
			set  
			{
				List[index] = value;
			}
		}

		public int Add( [%<variable type="custom" name="datatype"/>%] value )  
		{
			return( List.Add( value ) );
		}

		public int IndexOf( [%<variable type="custom" name="datatype"/>%] value )  
		{
			return( List.IndexOf( value ) );
		}

		public void Insert( int index, [%<variable type="custom" name="datatype"/>%] value )  
		{
			List.Insert( index, value );
		}

		public void Remove( [%<variable type="custom" name="datatype"/>%] value )  
		{
			List.Remove( value );
		}

		public bool Contains( [%<variable type="custom" name="datatype"/>%] value )  
		{
			// If value is not of type [%<variable type="custom" name="datatype"/>%], this will return false.
			return( List.Contains( value ) );
		}

		protected override void OnInsert( int index, Object value )  {
			// Insert additional code to be run only when inserting values.
		}

		protected override void OnRemove( int index, Object value )  {
			// Insert additional code to be run only when removing values.
		}

		protected override void OnSet( int index, Object oldValue, Object newValue )  {
			// Insert additional code to be run only when setting values.
		}

		protected override void OnValidate( Object value )  {
			// This check is commented out since it doesn't work for all types
			//if ( value.GetType() != Type.GetType("[%<variable type="custom" name="datatype"/>%]") )
			//	throw new ArgumentException( "value must be of type [%<variable type="custom" name="datatype"/>%].", "value" );
		}
	}
}